package org.jpropelleralt.sequence.impl;

import org.jpropelleralt.sequence.Sequence;

/**
 * Implementations of {@link Sequence}
 * Includes sequences using a fixed step on each {@link Number} type.
 */
public class Sequences {

// AutoCode for Integer

	/**
	 * A {@link Sequence} of {@link Integer}s, incrementing and
	 * decrementing by a fixed step.  
	 */
	public static class IntegerStepSequence implements Sequence<Integer>{
		private final Integer step;
		
		/**
		 * Create a new {@link IntegerStepSequence}
		 * @param step	The increment/decrement size
		 */
		public IntegerStepSequence(Integer step) {
			this.step = step;
		}
		
		@Override
		public Integer next(Integer t) {
			return t + step;
		}
		@Override
		public Integer previous(Integer t) {
			return t - step;
		}
	}
	
	/**
	 * Make a new {@link IntegerStepSequence}, with specified step
	 * @param step		The fixed step
	 * @return			A new {@link IntegerStepSequence}
	 */
	public static IntegerStepSequence stepSequence(Integer step) {
		return new IntegerStepSequence(step);
	}

// End of AutoCode for Integer


// AutoCode for Long

	/**
	 * A {@link Sequence} of {@link Long}s, incrementing and
	 * decrementing by a fixed step.  
	 */
	public static class LongStepSequence implements Sequence<Long>{
		private final Long step;
		
		/**
		 * Create a new {@link LongStepSequence}
		 * @param step	The increment/decrement size
		 */
		public LongStepSequence(Long step) {
			this.step = step;
		}
		
		@Override
		public Long next(Long t) {
			return t + step;
		}
		@Override
		public Long previous(Long t) {
			return t - step;
		}
	}
	
	/**
	 * Make a new {@link LongStepSequence}, with specified step
	 * @param step		The fixed step
	 * @return			A new {@link LongStepSequence}
	 */
	public static LongStepSequence stepSequence(Long step) {
		return new LongStepSequence(step);
	}

// End of AutoCode for Long


// AutoCode for Float

	/**
	 * A {@link Sequence} of {@link Float}s, incrementing and
	 * decrementing by a fixed step.  
	 */
	public static class FloatStepSequence implements Sequence<Float>{
		private final Float step;
		
		/**
		 * Create a new {@link FloatStepSequence}
		 * @param step	The increment/decrement size
		 */
		public FloatStepSequence(Float step) {
			this.step = step;
		}
		
		@Override
		public Float next(Float t) {
			return t + step;
		}
		@Override
		public Float previous(Float t) {
			return t - step;
		}
	}
	
	/**
	 * Make a new {@link FloatStepSequence}, with specified step
	 * @param step		The fixed step
	 * @return			A new {@link FloatStepSequence}
	 */
	public static FloatStepSequence stepSequence(Float step) {
		return new FloatStepSequence(step);
	}

// End of AutoCode for Float


// AutoCode for Double

	/**
	 * A {@link Sequence} of {@link Double}s, incrementing and
	 * decrementing by a fixed step.  
	 */
	public static class DoubleStepSequence implements Sequence<Double>{
		private final Double step;
		
		/**
		 * Create a new {@link DoubleStepSequence}
		 * @param step	The increment/decrement size
		 */
		public DoubleStepSequence(Double step) {
			this.step = step;
		}
		
		@Override
		public Double next(Double t) {
			return t + step;
		}
		@Override
		public Double previous(Double t) {
			return t - step;
		}
	}
	
	/**
	 * Make a new {@link DoubleStepSequence}, with specified step
	 * @param step		The fixed step
	 * @return			A new {@link DoubleStepSequence}
	 */
	public static DoubleStepSequence stepSequence(Double step) {
		return new DoubleStepSequence(step);
	}

// End of AutoCode for Double




}
